package com.example.appjetpackcompose

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color


// 主要方法，被此方法包裹的 Composable 函数都会被设置为自定义主题
@Composable
fun DefaultTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),  // 默认根据系统来设置是否为暗夜模式
    content: @Composable () -> Unit  // 被传入的 Composable 函数
){
    val colors = if (darkTheme) {
        DarkColor
    } else {
        LightColor
    }

    MaterialTheme(colors = colors) { // 将设置好的色值传入
        content()
    }
}

val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)

private val DarkColor = darkColors(
    primary = Purple80,
    secondary = PurpleGrey80,
)

private val LightColor = lightColors(
    primary = Purple40,
    secondary = PurpleGrey40,
)